package au.edu.swin.videoshop.bean;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class RentalStatus implements Serializable,Comparable {
	private static final Map sMap = new HashMap();
	
	public static final RentalStatus OPEN = new RentalStatus(0, "Open", "Open");
	public static final RentalStatus RETURNED = new RentalStatus(1, "Returned", "Returned");
	
	private int mOrder;
	private String mName;
	private String mDescription;
	
	private RentalStatus(int order, String name, String description) {
		mOrder = order;
		mName = name;
		mDescription = description;
		
		sMap.put(name, this);
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return mName;
	}
	
	/**
	 * @return the description
	 */
	public String getDescription() {
		return mDescription;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return mName;
	}
	
	public static RentalStatus getInstance(String name) {
		return (RentalStatus)sMap.get(name);
	}

	/* (non-Javadoc)
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(Object o) {
		return mOrder - ((RentalStatus)o).mOrder;
	}
}